<?php

namespace app\models;

use Yii;
use yii\web\IdentityInterface;

/**
 * This is the model class for table "user".
 *
 * @property string $UserID
 * @property string $UserName
 * @property string $UserNameKana
 * @property string $Password
 * @property string $TellNumber
 * @property string $MailAddress
 * @property string $WorkingStartTime
 * @property string $WorkingEndTime
 * @property integer $ManagementFlag
 * @property integer $ClientDeleteFlag
 * @property integer $ReportFlag
 * @property integer $ScheduleFlag
 * @property integer $FailureCount
 * @property integer $LockStatus
 * @property string $InsertDateTime
 * @property string $UpdateDatetime
 * @property string $InsertID
 * @property string $UpdateID
 * @property integer $DeleteFlag
 *
 * @property Passwordmanagement[] $passwordmanagements
 * @property Userlogin $userlogin
 */
class User extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'user';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['UserID'], 'required'],
            [['WorkingStartTime', 'WorkingEndTime', 'InsertDateTime', 'UpdateDatetime'], 'safe'],
            [['ManagementFlag', 'ClientDeleteFlag', 'ReportFlag', 'ScheduleFlag', 'FailureCount', 'LockStatus', 'DeleteFlag'], 'integer'],
            [['UserID', 'InsertID', 'UpdateID'], 'string', 'max' => 10],
            [['UserName', 'UserNameKana', 'Password'], 'string', 'max' => 20],
            [['TellNumber'], 'string', 'max' => 15],
            [['MailAddress'], 'string', 'max' => 255]
        ];
    }

    public static function findIdentity($id){
        return static::findOne($id);
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'UserID' => Yii::t('app', 'User ID'),
            'UserName' => Yii::t('app', 'User Name'),
            'UserNameKana' => Yii::t('app', 'User Name Kana'),
            'Password' => Yii::t('app', 'Password'),
            'TellNumber' => Yii::t('app', 'Tell Number'),
            'MailAddress' => Yii::t('app', 'Mail Address'),
            'WorkingStartTime' => Yii::t('app', 'Working Start Time'),
            'WorkingEndTime' => Yii::t('app', 'Working End Time'),
            'ManagementFlag' => Yii::t('app', 'Management Flag'),
            'ClientDeleteFlag' => Yii::t('app', 'Client Delete Flag'),
            'ReportFlag' => Yii::t('app', 'Report Flag'),
            'ScheduleFlag' => Yii::t('app', 'Schedule Flag'),
            'FailureCount' => Yii::t('app', 'Failure Count'),
            'LockStatus' => Yii::t('app', 'Lock Status'),
            'InsertDateTime' => Yii::t('app', 'Insert Date Time'),
            'UpdateDatetime' => Yii::t('app', 'Update Datetime'),
            'InsertID' => Yii::t('app', 'Insert ID'),
            'UpdateID' => Yii::t('app', 'Update ID'),
            'DeleteFlag' => Yii::t('app', 'Delete Flag'),
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getPasswordmanagements()
    {
        return $this->hasMany(Passwordmanagement::className(), ['UserID' => 'UserID']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getUserlogin()
    {
        return $this->hasOne(Userlogin::className(), ['UserID' => 'UserID']);
    }
}
